package cn.kkcxy.blog.oss.storage;

import io.minio.GetObjectArgs;
import io.minio.MinioClient;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.io.InputStream;

/**
 * @BelongsProject: kkcxy-blog
 * @BelongsPackage: cn.kkcxy.blog.oss.service
 * @Author: kkcxy
 * @CreateTime: 2024-10-19 18:48
 * @Description: Minio 操作类
 * @Version: 1.0
 */
@Slf4j
@Component
public class MinioStorage {

    @Resource
    private MinioClient minioClient;

    /**
     * 下载文件
     */
    public InputStream downLoad(String bucket, String objectName) throws Exception {
        return minioClient.getObject(
                GetObjectArgs.builder().bucket(bucket).object(objectName).build()
        );
    }
}
